package Demo05;

public class Main {
}


class Solution {
    public static void main(String[] args) {
        System.out.println(distinctSubseqII("abc"));
    }

    public static int distinctSubseqII(String s) {
        final int MOD = 1000000007;
        int last = 1;
        int[] dp = new int[26];
        int res = 0;
        for (int i = 0; i < s.length(); i++) {
            int tmp = last;
            res = (last + (last - dp[s.charAt(i) - 'a'] + MOD) % MOD) % MOD;
            last = res;
            dp[s.charAt(i) - 'a'] = tmp;
        }
        return (res - 1 + MOD) % MOD;
    }
}